package com.sprouting.personal.service;

import cn.hutool.core.date.DateTime;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sprouting.personal.dao.UploadFileDao;
import com.sprouting.personal.model.entity.UploadFile;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 上传文件信息表
 *
 * @author ：LX（长沙麓谷）
 * @date 创建时间： 2022/9/16 1:20
 */
@Service
@Slf4j
public class UploadFileService extends ServiceImpl<UploadFileDao, UploadFile> {

    @Resource
    private UploadFileDao uploadFileDao;

    /**
     * 根据绑定ID查询上传文件
     * @param bindingId 绑定ID
     * @return
     */
    public List<UploadFile> getUploadFileByBindingId(String bindingId) {
        return uploadFileDao.getUploadFileByBindingId(bindingId);
    }

    /**
     * 根据绑定ID查询上传文件，不含临时文件
     * @param bindingId 绑定ID
     */
    public List<UploadFile> getUploadFileByBindingIdNotTemp(String bindingId) {
        return uploadFileDao.getUploadFileByBindingIdNotTemp(bindingId);
    }

    /**
     * 根据主键查询上传文件
     * @param id 上传文件主键ID
     * @return
     */
    public UploadFile getUploadFileById(String id) {
        return uploadFileDao.getUploadFileById(id);
    }

    /**
     * 根据绑定ID查询上传文件
     * @param idList 绑定ID
     * @return
     */
    public List<UploadFile> getUploadFileByBindingIdList(List<String> idList) {
        return uploadFileDao.getUploadFileByBindingIdList(idList);
    }

    /**
     * 查询临时文件超时的
     * @param dateTime 超时时间
     * @return
     */
    public List<UploadFile> getUploadFileTempTimedOut(DateTime dateTime) {
        return uploadFileDao.getUploadFileTempTimedOut(dateTime);
    }

    /**
     * 根据保存路径找到文件信息
     * @param path 保存路径
     * @return
     */
    public UploadFile getUploadFileBySavePath(String path) {
        return uploadFileDao.getUploadFileBySavePath(path);
    }


}
